package com.ruoqing.utils.common;


import java.lang.reflect.Array;
import java.util.Collection;
import java.util.Map;

/**
	* @author YaoXian
	* @title: ObjectUtils
	* @projectName ruoxi-blog
	* @description: 若兮微服务 - 工具模块 - 判断对象是否为空或null
	* @date 2020-12-05 22:24
	*/

public class ObjectUtils {
		
		public static boolean isNull(Object obj) {
				return obj == null;
		}
		
		public static boolean isNotNull(Object obj) {
				return !isNull(obj);
		}
		
		public static boolean isEmpty(Object obj) {
				if (obj == null) {
						return true;
				} else if (obj instanceof CharSequence) {
						return ((CharSequence) obj).length() == 0;
				} else if (obj instanceof Collection) {
						return ((Collection) obj).isEmpty();
				} else if (obj instanceof Map) {
						return ((Map) obj).isEmpty();
				} else if (obj.getClass().isArray()) {
						return Array.getLength(obj) == 0;
				}
				
				return false;
		}
		
		public static boolean isNotEmpty(Object obj) {
				return !isEmpty(obj);
		}
}